let express = require('express');
let router = express.Router();
let config = require('../conf/config');
let request = require('request');

/* GET home page. */
router.all('/*', function(req, res, next) {
    // let options = {
    //     method: req.method,
    //     uri: "http://localhost:3334/" + req.path,
    //     qs: req.query,
    //     headers: req.headers,
    //     body: req.body
    // };

    request(config.apiPath + req.path, (error, response, body) => {
        if (!error) {
            let info = JSON.parse(body);
            res.json(info);
        }else{
            res.json({error, response, body});
        }
    });

});

module.exports = router;
